package com.dalin.framework.dao.imple;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.dalin.framework.dao.DbConn;
import com.dalin.framework.vos.ColumnBaseInfoVo;
/*****************************************************************************
 * @content: sqlserver连接数据库                                              *
 * @author : 那建林                                                          *
 * @crtDate: 2009-06-15                                                     *
 * @version: 1.0                                                            *
 ****************************************************************************/
public class SqlserverConnection 
		extends AbstractConnection 
			implements DbConn {

	public SqlserverConnection(String driverClassName, String url,
			String userName, String userPswd) {
		super(driverClassName, url, userName, userPswd);
	}

	public List<Map> queryData(String sql) throws Exception {
		return super.queryData(sql);
	}

	public int executeUpdate(String sql) throws Exception {
		return super.executeUpdate(sql);
	}

	public Set<String> queryTables() throws Exception {
		Set<String> rtnSet = new HashSet<String>();
		List<Map> dataList = this.queryData(
				"select name from sysobjects where xtype='u' and status>=0");
		for (Map m : dataList) {
			rtnSet.add(m.get("name").toString());
		}
		return rtnSet;
	}

	public Set<ColumnBaseInfoVo> queryColumnInfosByTable(String tableName) throws Exception {
		return super.queryColumnInfosByTableName(tableName);
	}

	public String getJavaTypeFromColumnType(String columnType,
			int columnLength, int decimalLength) {
		if ("int".equals(columnType)) {
			return "Long";
		} else if ("datetime".equals(columnType)) {
			return "Date";
		} else {
			return "String";
		}
	}

	public boolean connectTest() {
		// TODO Auto-generated method stub
		return false;
	}

	public void addColumn(String tableName, String columnName,
			String columnType, Integer columnLength, boolean nullable)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void alterColumn(String tableName, String originalColumnName,
			String newColumnName, String columnType, Integer columnLength,
			boolean nullable) throws Exception {
		// TODO Auto-generated method stub
		
	}

	public void dropColumn(String tableName, String columnName)
			throws Exception {
		// TODO Auto-generated method stub
		
	}

	public Serializable createObj(Object entity) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
}
